package com.starry.push.netty.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @author WuChao
 * @version 1.0
 * @date 2020/11/3 14:38
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ResponseResult implements Serializable {
    private Integer code;
    private String msg;
    @JsonFormat(shape = JsonFormat.Shape.STRING,pattern = "yyyy-MM-dd HH:mm:ss",  timezone = "GMT+8")
    private LocalDateTime nowTime;
    private Object body;

    public static ResponseResult success() {
        return ResponseResult.builder()
                .code(200)
                .msg("成功")
                .nowTime(LocalDateTime.now())
                .build();
    }
    public static ResponseResult error() {
        return ResponseResult.builder()
                .code(500)
                .msg("失败")
                .nowTime(LocalDateTime.now())
                .build();
    }

    public static ResponseResult success(Object body) {
        return ResponseResult.builder()
                .code(200)
                .msg("成功")
                .body(body)
                .nowTime(LocalDateTime.now())
                .build();
    }

    public static ResponseResult error(Object body) {
        return ResponseResult.builder()
                .code(500)
                .msg("失败")
                .body(body)
                .nowTime(LocalDateTime.now())
                .build();
    }

}
